package fl.ass.service.api;

import cn.cmm.base.framework.utils.BaseLogUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cmm.mid.core.framework.page.Pager;
import fl.ass.facade.api.IAssEvaluationApi;
import fl.ass.facade.dto.AssPrdEvaluationDTO;
import fl.ass.facade.dto.MessageDTO;
import fl.ass.service.service.IAssPrdEvaluationService;

/**
 * 资产评估API
 * @author zy
 *
 */
@Component
public class AssEvaluationApi implements IAssEvaluationApi {
	
	private static final Logger logger = LoggerFactory.getLogger(AssEvaluationApi.class);
	
	@Autowired
	private IAssPrdEvaluationService assPrdEvaluationService;

	/* (non-Javadoc)
	 * @see fl.ass.facade.api.IAssEvaluationApi#saveAssPrdEvaluation(fl.ass.facade.dto.AssPrdEvaluationDTO)
	 */
	@Override
	public MessageDTO<String> saveAssPrdEvaluation(AssPrdEvaluationDTO dto) {
		MessageDTO<String> response = new MessageDTO<String>();
		if(null == dto){
			response.setMessage("parameter：dto is can not be null");
		}
		try {
			assPrdEvaluationService.add(dto);
			response.setSuccess(true);
		} catch (Exception e) {
            BaseLogUtils.newLogger("异常!" + e.getMessage()).setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

	/* (non-Javadoc)
	 * @see fl.ass.facade.api.IAssEvaluationApi#updateAssPrdEvaluation(fl.ass.facade.dto.AssPrdEvaluationDTO)
	 */
	@Override
	public MessageDTO<String> updateAssPrdEvaluation(AssPrdEvaluationDTO dto) {
		MessageDTO<String> response = new MessageDTO<String>();
		if(null == dto){
			response.setMessage("parameter：dto is can not be null");
		}
		try {
			assPrdEvaluationService.modify(dto);
			response.setSuccess(true);
		} catch (Exception e) {
            BaseLogUtils.newLogger("异常!" + e.getMessage()).setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

	/* (non-Javadoc)
	 * @see fl.ass.facade.api.IAssEvaluationApi#findAssPrdEvaluationById(java.lang.Long)
	 */
	@Override
	public MessageDTO<AssPrdEvaluationDTO> findAssPrdEvaluationById(Long id) {
		MessageDTO<AssPrdEvaluationDTO> response = new MessageDTO<AssPrdEvaluationDTO>();
		if(null == id){
			response.setMessage("parameter：id is can not be null");
		}
		try {
			AssPrdEvaluationDTO dto = assPrdEvaluationService.selectById(id);
			if(null != dto){
				response.setData(dto);
			}
			response.setSuccess(true);
		} catch (Exception e) {
            BaseLogUtils.newLogger("异常!" + e.getMessage()).setThrowable(e).info();
			response.setMessage(e.getMessage());
		}
		return response;
	}

	/* (non-Javadoc)
	 * @see fl.ass.facade.api.IAssEvaluationApi#findAssPrdEvaluationListByPage(cmm.mid.core.framework.page.Pager)
	 */
	@Override
	public Pager findAssPrdEvaluationListByPage(Pager page) {
		return assPrdEvaluationService.findAssPrdEvaluationListByPage(page);
	}
	
}
